#!/usr/bin/env python3
import subprocess
import sys
import logging

# 设置日志格式
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s | %(levelname)-8s | %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S'
)
logger = logging.getLogger(__name__)

# 需要安装的依赖
DEPENDENCIES = [
    "librosa",
    "soundfile",
    "numpy",
    "demucs",
    "torch",
    "torchaudio",
]

def install_dependencies():
    """安装所有必要的依赖"""
    logger.info("开始安装依赖...")
    
    success = True
    for package in DEPENDENCIES:
        try:
            logger.info(f"正在安装 {package}...")
            subprocess.run([sys.executable, "-m", "pip", "install", package], check=True)
            logger.info(f"{package} 安装成功")
        except subprocess.CalledProcessError as e:
            logger.error(f"{package} 安装失败: {e}")
            success = False
            
    if success:
        logger.info("所有依赖安装成功")
    else:
        logger.error("部分依赖安装失败，请检查")
        
    return success

if __name__ == "__main__":
    install_dependencies() 